using System;
using System.Text;

namespace P2PGrid
{
    class Program
    {
        /// <summary>
        /// Application starts here. Create an instance of this class and use it as the main object.
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            P2PApp app = new P2PApp();

        	Console.WriteLine("Input exit to quit");          
            while (true)
            {
                // get the user iput
                string msg = Console.ReadLine();
                if (msg != null)
                {
                    // if user input exit then exit the program
                    if (msg == "exit")
                        break;  
                    // delegate to Commander to process the input
                    MessagerProcessor u = new MessagerProcessor(app);
                    u.Process(msg);
                }
            }

            Console.WriteLine("OK that does it! 88");
            //Clean up before finish
            app.CloseAll();
            GC.Collect();
            GC.WaitForPendingFinalizers();            
        }
    }
}
